//package com.daxt.controller.filemanager;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.daxt.common.result.*;
//import com.daxt.mapper.use.UseUserRecordLogMapper;
//import com.daxt.model.dto.ProcessDto;
//import com.daxt.model.service.use.vo.UseBorrowApply;
//import com.daxt.model.service.use.vo.UseUserRecordLog;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.activiti.engine.RepositoryService;
//import org.activiti.engine.repository.ProcessDefinition;
//import org.apache.commons.io.IOUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.util.StringUtils;
//import org.springframework.web.bind.annotation.*;
//import org.springframework.web.multipart.MultipartFile;
//
//
//import javax.servlet.ServletOutputStream;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.InputStream;
//import java.util.ArrayList;
//import java.util.List;
//
//@Api(tags = "工作流")
//@RestController
//@RequestMapping("/workflow")
//public class WorkflowController {
//
//
//    @Autowired
//    private RepositoryService rep;
//
//
//    @ApiOperation("上传一个工作流文件")
//    @PostMapping("/uploadWorkflow")
//    @ResponseBody
//    public Result<String> fileUpload(
//            @ApiParam("工作流文件") @RequestParam(value = "file", required = false) MultipartFile file) {
//        try {
////            MultipartFile file = uploadFile;
//            String filename = file.getOriginalFilename();
//            InputStream is = file.getInputStream();
//            rep.createDeployment().addInputStream(filename, is).deploy();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return ResultUtil.success();
//    }
//
//
//    @ApiOperation("查询已部署工作流列表")
//    @PostMapping("/processList")
//    @ResponseBody
//    public Result<List<ProcessDefinition>> getlist(@RequestParam("current") int current, @RequestParam("rowCount") int rowCount) {
//        int firstrow = (current - 1) * rowCount;
//        List<ProcessDefinition> list = rep.createProcessDefinitionQuery().listPage(firstrow, rowCount);
//        int total = rep.createProcessDefinitionQuery().list().size();
//        List<ProcessDto> result = new ArrayList<>();
//        list.forEach((ProcessDefinition pd)->{
//            ProcessDto pDto = new ProcessDto();
//            pDto.setId(pd.getId());
//            pDto.setDeploymentId(pd.getDeploymentId());
//            pDto.setDiagramResourceName(pd.getDiagramResourceName());
//            pDto.setKey(pd.getKey());
//            pDto.setName(pd.getName());
//            pDto.setResourceName(pd.getResourceName());
//
//            result.add(pDto);
//
//        });
//
//        return ResultUtil.success(list);
//    }
//
//    @ApiOperation("查看工作流图片")
//    @GetMapping("/showResource")
//    public void export(@RequestParam("pdid") String pdid, @RequestParam("resource") String resource,
//                       HttpServletResponse response) throws Exception {
//        ProcessDefinition def = rep.createProcessDefinitionQuery().processDefinitionId(pdid).singleResult();
//        InputStream is = rep.getResourceAsStream(def.getDeploymentId(), resource);
//        ServletOutputStream output = response.getOutputStream();
//        IOUtils.copy(is, output);
//    }
//
//
////    @ApiOperation("发起一个借阅流程")
////    @RequestMapping(value = "/startleave", method = RequestMethod.POST)
////    @ResponseBody
////    public Result<String> start_leave(UseBorrowApply apply) {
////        String userid = (String) session.getAttribute("username");
////        Map<String, Object> variables = new HashMap<String, Object>();
////        variables.put("applyuserid", userid);
////        variables.put("deptleader", apply.getDeptleader());
////        leaveservice.startWorkflow(apply, userid, variables);
////        return new MSG("sucess");
////    }
//
//}
